N = int(1e5 + 5)
stack = [0 for i in range(0, N)]
ss = input()
top = 0
flag = 0
for i in ss:
	if(i == '(') :
		top = top + 1
		stack[top] = 1
	if(i == '[') :
		top = top + 1
		stack[top] = 2

	if(i == ')') :
		if(stack[top] == 1):
			top = top - 1
		else:
			flag = True
			break
	if(i == ']') :
		if(stack[top] == 2):
			top = top - 1
		else:
			flag = True
			break

if(flag or top != 0):
	print("NO")
else:
	print("YES")